# !/bin/bash
token=(`jq '.token' bank.json`)
cityCode=(`jq -r '.citys[] .fullCode' citys.json`)
bankCode=(`jq -r '.banks[] .code' bank.json`)
# sign=(`jq '.data[] .bank' bank.json`)
# provinces=(`jq '.data[] .sign' bank.json`)
# # year=(`cat bank.json | jq '.data[] .year'`)
# type=(`jq '.data[] .type' bank.json`)
# parentId=(`jq '.data[] .parentId' bank.json`)
# relatedId=(`jq '.data[] .relatedId' bank.json`)
# costPackage=(`jq '.data[] .costPackage' bank.json`)
# quota=(`jq '.data[] .quota' bank.json`)

echo '\n======================================\n' > bank.log

len=${#bankCode[@]}
clen=${#cityCode[@]}
for((i=0; i<$len; i++)) do
	for((j=0; j<$clen; j++)) do
		echo $i '   -    ' $j ' cityCode:  '  ${bankCode[$i]} ' cityCode:  '  ${cityCode[$j]}
		echo 'https://app923.eapps.dingtalkcloud.com/api/web/bank/branch/options?cityCode='${cityCode[$j]}'bankCode='${bankCode[$i]}'&1686551772997'
		echo '{ "bankCode": "'${bankCode[$i]}'", "cityCode": "'${cityCode[$j]}'", "branch": ' >> bank.log
			# echo $i ' ---- ' $token ' --- ' ' sign: ' ${sign[$i]} ' year: ' ${year[$i]} ' type: ' ${type[$i]} ' parentId: ' ${parentId[$i]} ' relatedId: ' ${relatedId[$i]} ' costPackage: ' ${costPackage[$i]} ' quota: ' ${quota[$i]}
		curl 'https://app923.eapps.dingtalkcloud.com/api/web/bank/branch/options?cityCode='${cityCode[$j]}'&bankCode='${bankCode[$i]}'&16865517729971' \
			-H 'sec-ch-ua: "Chromium";v="96"' \
			-H 'entcode: EC3PXQR12VPV0H' \
			-H 'sec-ch-ua-mobile: ?0' \
			-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 13_0_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 DingTalk(7.0.30-macOS-30013449) nw Channel/201200 Architecture/x86_64' \
			-H 'beta: 0' \
			-H 'lang: zh' \
			-H 'tokenid: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJtYXljdXJfand0X2Rldl9pZCIsInN1YiI6IlVJMjU2NzAwNzY1NjA1NzY2MzQiLCJpYXQiOjE2ODYxMjU0ODgsImF1ZCI6IldFQiIsImV4cCI6MTY4ODcxNzQ4OH0.Q2KvEAmCMb1BWC8wqTgnr-I6YA2ahGovAUgAyOhAW0Y' \
			-H 'sec-ch-ua-platform: "Mac OS X"' \
			-H 'accept: */*' \
			-H 'cookie: gr_user_id=f9fbc398-d08d-437f-a26f-37dbf1cd5ee0' \
			-H 'cookie: entCode=EC3PXQR12VPV0H' \
			-H 'cookie: org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=zh' \
			-H 'cookie: br-client=eb60a83c-31c1-45d6-9e6e-465199b39521' \
			-H 'cookie: 9d14096445680f4b_gr_last_sent_cs1=UI25670076560576634' \
			-H 'cookie: 9d14096445680f4b_gr_session_id=782b16ec-ee30-41bb-ae91-1d183cd49817' \
			-H 'cookie: 9d14096445680f4b_gr_last_sent_sid_with_cs1=782b16ec-ee30-41bb-ae91-1d183cd49817' \
			-H 'cookie: 9d14096445680f4b_gr_session_id_sent_vst=782b16ec-ee30-41bb-ae91-1d183cd49817' \
			-H 'cookie: 9d14096445680f4b_gr_cs1=UI25670076560576634' \
			-H 'cookie: br-session-41a1e7a761264d90acdbe36c857a8427=9ef8639d-9001-4888-b1ec-07e280699ca7|1686550562571000|1686551770746000|25' \
			-H 'sec-fetch-site: same-origin' \
			-H 'sec-fetch-mode: cors' \
			-H 'sec-fetch-dest: empty' \
			-H 'referer: https://app923.eapps.dingtalkcloud.com/formrender/?corpId=dingf6a61f34e47c7a17a1320dcb25e91351' \
			-H 'accept-language: zh-CN,zh;q=0.9' \
			| jq '.data' >> bank.log
		echo ' },' >> bank.log

	done;
done;
